﻿@{
    Layout = "_ZjcLayout";
    ViewData["Title"] = "政教处";
}


<fieldset class="layui-elem-field" style="margin: 20px">
    <legend>处理学生奖惩</legend>
    <div class="layui-field-box">
        <div class="layui-row">
            <div class="layui-col-xs12 layui-col-md8">
                <fieldset class="layui-elem-field layui-field-title" style="background-color:#82A08E">
                    <legend><a style="color:black">学生奖励申请表</a></legend>
                </fieldset>
            </div>
            <div class="layui-col-xs6 layui-col-md4">
                <div class="layui-inline">
                    <input class="layui-input" name="id" id="awardid" autocomplete="off" placeholder="请输入学生ID">
                </div>
                <button class="layui-btn layui-btn-checked" data-type="reload" id="awardSearch">搜索</button>
            </div>
        </div>
        <table class="layui-hide" id="awardTable" lay-filter="awarduse"></table>
    </div>
</fieldset>



@section Scripts{

    <script src="~/layui-v2.5.5/layui/layui.all.js" charset="utf-8"></script>
    <script src="~/js/jquery.js"></script>

    <script type="text/javascript">
        $("#awardSearch").click(function (event) {
            event.preventDefault()
        })
    </script>
    <script type="text/html" id="buttonl">
        {{#  if(d.state === '已拒绝'){ }}
        <span style="color: #D52B2B;">{{ d.state }}</span>
        {{#  } else if(d.state === '已通过') { }}
        <span style="color:#3BA250;">{{ d.state }}</span>
        {{#  } else { }}
        <span style="color: #1111EE;">{{ d.state }}</span>
        {{#  } }}
    </script>
    <script>
        layui.use('table', function () {
            var table = layui.table;
            table.render({
                elem: '#awardTable'
                , url: '/Api/AwardList'
                , cols: [[
                    { field: 'id', width: "6%", title: '编号', sort: true, fixed: true, event: 'awardset', style: 'cursor: pointer;' }
                    , { field: 'sid', width: "12%", title: '学号' }
                    , { field: 'studentName', width: "12%", title: '姓名' }
                    , { field: 'studentClass', width: "12%", title: '班级' }
                    , { field: 'content', width: "18%", title: '奖励详情' }
                    , { field: 'awardContent', width: "15%", title: '具体措施' }
                    , { field: 'applyTime', width: "15%", title: '申请时间', sort: true }
                    , { field: 'state', title: '审核状态',minWidth:50, templet: '#buttonl' }
                ]]
                , page: true
                , height: 472
            });
            var $ = layui.$, active = {
                reload: function () {
                    var awardid = $('#awardid');
                    var loading = layer.msg("数据加载中", {
                        icon: 16,
                        shade: 0.01
                    });
                    //表单赋值
                    $.ajax({
                        url: '/Api/ShowAwardList',
                        data: { id: awardid.val() },
                        type: "GET",
                        dataType: "JSON",
                        success: function (data) {
                            switch (data.code) {
                                case 0:
                                    awardData = data;
                                    table.render({
                                        elem: '#awardTable'
                                        , cols: [[
                                            { field: 'id', width: "6%", title: '编号', sort: true, fixed: true, event: 'awardset', style: 'cursor: pointer;' }
                                            , { field: 'sid', width: "12%", title: '学号' }
                                            , { field: 'studentName', width: "12%", title: '姓名' }
                                            , { field: 'studentClass', width: "12%", title: '班级' }
                                            , { field: 'content', width: "18%", title: '奖励详情' }
                                            , { field: 'awardContent', width: "15%", title: '具体措施' }
                                            , { field: 'applyTime', width: "15%", title: '申请时间', sort: true }
                                            , { field: 'state', title: '审核状态',minWidth:50, templet: '#buttonl' }
                                        ]]
                                        , page: true
                                        , data: awardData.award
                                        , height: 472
                                    });
                                    break;
                                case 270:
                                    layer.alert("数据不存在哦！请重新试试", { icon: 2 });
                                    break;
                                case 280:
                                    table.render({
                                        elem: '#awardTable'
                                        , url: '/Api/AwardList'
                                        , cols: [[
                                            { field: 'id', width: "6%", title: '编号', sort: true, fixed: true, event: 'awardset', style: 'cursor: pointer;' }
                                            , { field: 'sid', width: "12%", title: '学号' }
                                            , { field: 'studentName', width: "12%", title: '姓名' }
                                            , { field: 'studentClass', width: "12%", title: '班级' }
                                            , { field: 'content', width: "18%", title: '奖励详情' }
                                            , { field: 'awardContent', width: "15%", title: '具体措施' }
                                            , { field: 'applyTime', width: "15%", title: '申请时间', sort: true }
                                            , { field: 'state', title: '审核状态', minWidth:50, templet: '#buttonl' }
                                        ]]
                                        , page: true
                                        , height: 472
                                    });
                                    break;
                                default:
                                    layer.alert("数据异常，你再试试呗", { icon: 3 });
                            }
                            layer.close(loading);
                        }
                    })
                }
            };
            $('#awardSearch').on('click', function () {
                var type = $(this).data('type');
                active[type] ? active[type].call(this) : '';
            });
            //监听奖励表单元格事件
            table.on('tool(awarduse)', function (obj) {
                var data = obj.data;
                if (obj.event === 'awardset') {
                    layer.open({
                        type: 2,
                        area: ['600px', '820px'],
                        title: '奖励消息处理',
                        content: ['/ZJC/HandleAward?id=' + data.id, 'no'],
                    });
                }
            });

        });
    </script>

}
